<%@ page language="java" import="dao.*" pageEncoding="UTF-8" %>
<%@ page language="java" import="java.util.*" %>
<%@page import="util.*" %>


<%@ include file="head.jsp" %>
<script src="js/jquery.validate.js"></script>
<link rel="stylesheet" href="js/layer/theme/default/layer.css"/>
<script src="js/layer/layer.js"></script>
<link href="js/h5upload/h5upload.css" rel="stylesheet">
<script src="js/h5upload/h5upload.js"></script>
<link rel="stylesheet" href="js/umeditor/themes/default/css/umeditor.css"/>
<script src="js/umeditor/umeditor.config.js"></script>
<script src="js/umeditor/umeditor.min.js"></script>

<div style="padding: 10px">


    <% if (request.getSession().getAttribute("username") == null || "".equals(request.getSession().getAttribute("username"))) { %>
    <script>
        alert('对不起,请您先登陆!');
        location.href = 'login.jsp';
    </script>
    <%
            return;
        } %>


    <div class="container"><!-- 使用bootstrap css框架，container定宽，并剧中 https://v3.bootcss.com/css/#overview-container -->
        <div class="panel panel-default">
            <div class="panel-heading">
                添加商品信息:
            </div>
            <div class="panel-body">
                <form action="shangpinxinxi.jsp?a=insert" method="post" name="form1" id="form1"><!-- form 标签开始 -->
                    <div class="form-group">
                        <div class="row">
                            <label style="width: 120px;min-height:18px;text-align: right" class="col-sm-2">商品编号</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" style="width:150px;" readonly="readonly"
                                       id="shangpinbianhao" name="shangpinbianhao" value="<%= Info.getID() %>"/></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="width: 120px;min-height:18px;text-align: right" class="col-sm-2">商品名称<span
                                    style="color: red;">*</span></label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" style="width:250px;" data-rule-required="true"
                                       data-msg-required="请填写商品名称" id="shangpinmingcheng" name="shangpinmingcheng"
                                       value=""/></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="width: 120px;min-height:18px;text-align: right" class="col-sm-2">商品图片<span
                                    style="color: red;">*</span></label>
                            <div class="col-sm-8">
                                <input type="hidden" data-rule-required="true" data-msg-required="请填写商品图片"
                                       id="shangpintupian" name="shangpintupian" value=""/>
                                <script>showUploadImages("#shangpintupian")</script>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="width: 120px;min-height:18px;text-align: right" class="col-sm-2">商品分类<span
                                    style="color: red;">*</span></label>
                            <div class="col-sm-8">
                                <select class="form-control class_shangpinfenlei8" data-value=""
                                        data-rule-required="true" data-msg-required="请填写商品分类" id="shangpinfenlei"
                                        name="shangpinfenlei" style="width:250px"><%
                                    List<HashMap> select = new CommDAO().select("SELECT * FROM shangpinfenlei ORDER BY id desc");
                                %>
                                    <% for (HashMap m : select) { %>
                                    <option value="<%= m.get("id") %>"><%= m.get("fenleimingcheng") %>
                                    </option>
                                    <% } %>
                                </select></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="width: 120px;min-height:18px;text-align: right" class="col-sm-2">售价<span
                                    style="color: red;">*</span></label>
                            <div class="col-sm-8">
                                <input type="number" class="form-control" style="width:150px;" step="0.01"
                                       data-rule-required="true" data-msg-required="请填写售价" number="true"
                                       data-msg-number="输入一个有效数字" id="shoujia" name="shoujia" value=""/></div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="row">
                            <label style="width: 120px;min-height:18px;text-align: right" class="col-sm-2">描述<span style="color: #ff0000;">*</span></label>
                            <div class="col-sm-8">

                                <textarea style="width: 80%;height: 120px" class="form-control" data-rule-required="true" data-msg-required="请填写描述" id="miaoshu" name="miaoshu"></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="width: 120px;min-height:18px;text-align: right" class="col-sm-2">发布人</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" style="width:150px;" readonly="readonly"
                                       id="faburen" name="faburen"
                                       value="<%= request.getSession().getAttribute("username") !=null ? request.getSession().getAttribute("username") : "" %>"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <label style="width: 120px;min-height:18px;text-align: right" class="col-sm-2"> </label>
                            <div class="col-sm-8">
                                <input type="hidden" name="shangpinzhuangtai" id="shangpinzhuangtai" value="待售"/>
                                <button type="submit" class="btn btn-primary" name="Submit">
                                    提交
                                </button>
                                <button type="reset" class="btn btn-default" name="Submit2">
                                    重置
                                </button>
                            </div>
                        </div>
                    </div><!--form标签结束--></form>
            </div>
        </div>
        <!-- container定宽，并剧中结束 --></div>
    <script>
        $(function () {
            $('#form1').validate();
        });
    </script>
</div>
<%@ include file="foot.jsp" %>
